<template>
	<view class="container">
		<view class="topImg">
			<image src="/static/bmfw.png"></image>
			<view class="topText">
				<view class="topText1">{{ app.language.bmfwTitle }}</view>
				<view class="topText2">{{ app.language.bmfwJs }}</view>
			</view>
		</view>
		<!-- 用户信息 -->
		<view class="user" @click="handleUser">
			<image class="topImg" src="/static/user.png"></image>
			<view class="ggtext">
				<view class="bmfw">{{app.language.userInfo}}</view>
				<view class="wsb">{{app.language.djxg}}</view>
			</view>
		</view>
		<!-- 户籍咨询 -->
		<view class="bmfwItem">
			<h3>{{app.language.ztfw}}</h3>
			<view class="hjzx" v-for="item in hjzxList" @click="hanldUrl(item.path)">
				<view class="hjName">
					{{item.name}}
					<view class="motext">{{app.language.more}}</view>
				</view>
				<image :src="item.icon" class="icon"></image>
			</view>
			<view class="clear"></view>
		</view>
		<!-- 群众信息不完善的弹窗 -->
		<uni-popup ref="popup" type="bottom" border-radius="10px 10px 0 0" class="popup">
			<!-- <img src="/static/gb.png" alt="" class="gb" @click="handleGb"/> -->
			<view class="Ptitle">
				<button @click="handleUserInfo">{{app.language.improve}}</button>
			</view>
		</uni-popup>
		<!-- 工作人员信息不完善的弹窗 -->
		<uni-popup ref="gzrypopup" type="bottom" border-radius="10px 10px 0 0" class="popup">
			<!-- <img src="/static/gb.png" alt="" class="gb" @click="handlegzry"/> -->
			<view class="Ptitle">
				<button @click="handleUserInfo">{{app.language.improve}}</button>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import config from '../../config';
	const global = getApp().globalData;
	export default {
		data() {
			return {
				app: {
					global: global,
					name: global.appName,
					language: global.language
				},
				hjzxList: [{
						icon: "/static/gjbl.png",
						path: "/pages/bmfw/domicile",
						name: ""
					},
					{
						icon: "/static/ldydj.png",
						path: "/pages/hotel/list",
						name: ""
					},
					{
						icon: "/static/xgzm.png",
						path: "/pages/related/index",
						name: ""
					},
					{
						icon: "/static/zfjd.png",
						path: "/pages/supervise/index",
						name: ""
					},
					{
						icon: "/static/czfw.png",
						path: "/pages/rentHouse/index",
						name: ""
					},
					{
						icon: "/static/ylcs.png",
						path: "/pages/enter/index",
						name: ""
					},
				],
				token: "",
				userInfo: {}
			}
		},
		onLoad() {
			this.hjzxList[0].name = this.app.language.hjbl
			this.hjzxList[1].name = this.app.language.ldydj
			this.hjzxList[2].name = this.app.language.kjxgzm
			this.hjzxList[3].name = this.app.language.zfjdts
			this.hjzxList[4].name = this.app.language.czfwbb
			this.hjzxList[5].name = this.app.language.ylcsdj
			this.getToken()
		},

		methods: {
			// 获取缓存
			getToken() {
				let that = this
				uni.getStorage({
					key: 'loginData',
					success: function(res) {
						// that.form.reportType = res.data.userInfo.peopleType
						that.token = res.data.userInfo.appToken
						that.userInfo = res.data.userInfo
						console.log('that.userInfothat.userInfo', that.userInfo)
						if (that.token) {
							if (that.userInfo.peopleType == "people") {
								if (!that.userInfo.userName && !that.userInfo.idcard &&
									!that.userInfo.idcardFront && !that.userInfo.idcardBack) {
									that.$refs.popup.open('center')
								}
							} else {
								// 身份证号的
								console.log('3333333333',that.userInfo)
								// 身份作证号的
								if (!that.userInfo.agent) {
									that.$refs.gzrypopup.open('center')
									return
								}
								if (!that.userInfo.birthdate) {
									that.$refs.gzrypopup.open('center')
									return
								}
								if (!that.userInfo.idcard) {
									that.$refs.gzrypopup.open('center')
									return
								}
								if (!that.userInfo.nationality) {
									that.$refs.gzrypopup.open('center')
									return
								}
								if (!that.userInfo.policeNumber) {
									that.$refs.gzrypopup.open('center')
									return
								}
								if (!that.userInfo.personnelCategory) {
									that.$refs.gzrypopup.open('center')
									return
								}
								if (!that.userInfo.workTime) {
									that.$refs.gzrypopup.open('center')
									return
								}
								if (!that.userInfo.positionRank) {
									that.$refs.gzrypopup.open('center')
									return
								}
								if (!that.userInfo.marriage) {
									that.$refs.gzrypopup.open('center')
									return
								}
								if (!that.userInfo.height) {
									that.$refs.gzrypopup.open('center')
									return
								}
								if (!that.userInfo.weight) {
									that.$refs.gzrypopup.open('center')
									return
								}
								if (!that.userInfo.photo) {
									that.$refs.gzrypopup.open('center')
									return
								}
							}
						}
					}
				});
				console.log('that.userInfo', that.userInfo)
				// debugger

			},
			// 跳转页面
			hanldUrl(item) {
				// uni.navigateTo({
				// 	url: item,
				// });
				if (item == '/pages/supervise/index' || item == '/pages/rentHouse/index' || item == '/pages/enter/index') {
					if (this.token) {
						if (this.userInfo.peopleType == "people") {
							if (!this.userInfo.userName && !this.userInfo.idcard &&
								!this.userInfo.idcardFront && !this.userInfo.idcardBack) {
								uni.showToast({
									title: this.app.language.improve,
									icon: 'none',
								});
								return
							} else {
								uni.navigateTo({
									url: item,
								});
							}
						} else if (this.userInfo.peopleType == "police") {
							if (!this.userInfo.agent && !this.userInfo.birthdate && !this.userInfo.birthdate && !this
								.userInfo
								.nationality && !this.userInfo.policeNumber &&
								!this.userInfo.personnelCategory && !this.userInfo.department && !this.userInfo.workTime &&
								!
								this.userInfo.positionRank &&
								!this.userInfo.marriage && !this.userInfo.height && !this.userInfo.weight && !this.userInfo
								.photo) {
								uni.showToast({
									title: this.app.language.improve,
									icon: 'none',
								});
								return
							} else {
								uni.navigateTo({
									url: item,
								});
							}
						}
					} else {
						uni.navigateTo({
							url: '../login/login',
						});
					}
				} else {
					uni.navigateTo({
						url: item,
					});
				}
			},
			handleUserInfo() {
				if (this.token) {
					if (this.userInfo.peopleType == "people") {
						uni.navigateTo({
							url: '../user/peopleInfo',
						});
					} else if (this.userInfo.peopleType == "police") {
						uni.navigateTo({
							url: '../user/info',
						});
					}
				} else {
					uni.navigateTo({
						url: '../login/login',
					});
				}

			},
			handleUser() {
				if (this.token) {
					if (this.userInfo.peopleType == "people") {
						uni.navigateTo({
							url: '../user/peopleInfo',
						});
					} else if (this.userInfo.peopleType == "police") {
						uni.navigateTo({
							url: '../user/info',
						});
					}
				} else {
					uni.navigateTo({
						url: '../login/login',
					});
				}
			},
			// 关闭弹窗
			handleGb() {
				this.$refs.popup.close();
			},
			// 关闭弹窗
			handlegzry() {
				this.$refs.gzrypopup.close();
			}
		}
	}
</script>

<style>
	.container {
		width: 100%;
		height: 100%;
		background: #fff;
	}

	.bmfwItem {
		/* padding: 20rpx; */
		width: 100%;
		margin: 0 auto;
	}

	.bmfwT {
		font-weight: bold;
		font-size: 24rpx;
		margin-bottom: 20rpx;
		border-left: 2px solid #2f8ef9;
		padding-left: 10rpx;
	}

	.hjzx {
		font-size: 26rpx;
		width: 44%;
		float: left;
		box-shadow: 1px 1px 10rpx #ddd;
		text-align: center;
		padding: 41rpx 0;
		margin: 20rpx;
		border-radius: 10rpx;
		box-shadow: 1px 1px 10rpx #ddd;
	}
	
	/* .hjzx:nth-child(1) {
		background-image: linear-gradient(to right, #f0f1ff, #e0e0f7);
	} */

	.hjzx:nth-child(2) {
		background-image: linear-gradient(to right, #f0f1ff, #e0e0f7);
	}
	
	.hjzx:nth-child(3) {
		background-image: linear-gradient(to right, #e6faff, #d8f8fd);
	}
	
	.hjzx:nth-child(4) {
		background-image: linear-gradient(to right, #fff6f5, #f8e6dd);
	}
	
	.hjzx:nth-child(5) {
		background-image: linear-gradient(to right, #f0fcfe, #d0e8f9);
	}
	
	.hjzx:nth-child(6) {
		background-image: linear-gradient(to right, #f3f3ff, #e9eafd);
	}
	
	.hjzx:nth-child(7) {
		background-image: linear-gradient(to right, #eafaff, #caf2ef);
	}

	.clear {
		clear: both
	}

	.topImg {
		position: relative;
	}

	.topImg image {
		width: 100%;
		height: 300rpx;
	}

	.topText {
		color: #3675fe;
		position: absolute;
		top: 80rpx;
		left: 40rpx;
	}

	.topText1 {
		font-size: 41rpx;
		font-weight: bold;
	}

	.topText2 {
		font-size: 24rpx;
		color: #3675fe;
		margin-top: 10rpx;
		margin-left: 20rpx;
	}

	.icon {
		width: 60rpx;
		height: 59rpx;
		float: right;
		margin-right: 35rpx;
		position: relative;
		top: 14rpx;
	}

	.hjName {
		margin-top: 10rpx;
		float: left;
		margin-left: 35rpx;
		font-size: 30rpx;
		font-weight: bold;
		text-align: left;
	}

	.motext {
		font-size: 22rpx;
		margin-top: 14rpx;
		color: #727170;
		font-weight: 500;
	}

	.popup {
		z-index: 9999;
		position: relative;


	}

	.Ptitle {
		background-color: #fff;
		width: 512rpx;
		padding: 50rpx;
		text-align: center;
		border-radius: 10rpx;
	}

	.Ptitle button {
		font-size: 28rpx;
		background: #2f8ef9;
		color: #fff;
	}

	.gb {
		width: 30rpx !important;
		height: 30rpx !important;
		position: absolute;
		top: 10rpx;
		right: 10rpx;
		width: 90%;
	}

	.user {
		width: 100%;
		height: 170rpx;
		width: 95%;
		margin: 20rpx auto;
		border-radius: 10rpx;
		position: relative;
	}

	.user image {
		width: 100%;
		height: 100%;
		border-radius: 10rpx;
	}

	.ggtext {
		position: absolute;
		top: 22rpx;
		left: 124rpx;
	}

	.bmfw {
		font-size: 37rpx;
		color: #2270f3;
		margin-bottom: 18rpx;
		font-weight: bold;
		/* font-style: italic; */
		letter-spacing: 4rpx;
		/* 增加字符间距 */

	}

	.wsb {
		font-size: 23rpx;
		color: #fff;
		background-color: #2270f3;
		/* border-radius: 50%; */
		padding: 10rpx;
		text-align: center;
		border-radius: 27rpx;
	}
	
	.bmfwItem h3{
		color: #3f3f3f;
		padding-left: 20rpx;
		font-size: 30rpx;
		margin-top: 10rpx;
	}
</style>